package com.ebupt.migu.restapi;

import com.alibaba.fastjson.JSON;
import com.ebupt.migu.common.pojo.DelGroup;
import com.ebupt.migu.common.response.Response;
import com.ebupt.migu.common.response.ResponseBean;
import com.ebupt.migu.common.util.PropertiesUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * @author tz
 */
@Slf4j
public class GroupDetailDel {

    private static PropertiesUtil prop = new PropertiesUtil();
    private static String delUrl = prop.getValue("delUrl");

    /**
     * 客群销毁通知
     *
     * @param strategy
     */
    public static void del(Map<String, Object> strategy) {
        DelGroup delGroup = new DelGroup();
        delGroup.setPlanId(strategy.get("strategyId").toString())
                .setPlanName(strategy.get("strategyName").toString())
                .setCustomerId(strategy.get("groupId").toString());
        RestHttpPost post = new RestHttpPost();
        Response<String> response = post.doRest(delGroup, delUrl);
        if ("0000".equals(response.getHead().getResponseCode())) {
            ResponseBean res = JSON.parseObject(response.getResponse(), ResponseBean.class);
            log.info("code:{},msg:{}", res.getCode(), res.getMsg());
        }
    }

    /**
     * 客群销毁通知- G推
     *
     * @param customerId
     * @param uuid
     */
    public static void del(String customerId, String uuid) {
        DelGroup delGroup = new DelGroup();
        delGroup.setPlanId(uuid)
                .setPlanName(uuid)
                .setCustomerId(customerId);
        RestHttpPost post = new RestHttpPost();
        Response<String> response = post.doRest(delGroup, delUrl);
        if ("0000".equals(response.getHead().getResponseCode())) {
            ResponseBean res = JSON.parseObject(response.getResponse(), ResponseBean.class);
            log.info("code:{},msg:{}", res.getCode(), res.getMsg());
        }
    }
}
